import java.sql.Array;
import java.util.*;

// HJ102 字符统计
 public class HJ102 {

     public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         while (sc.hasNext()) {
             String str = sc.nextLine();
             Map<Character, Integer> map = new HashMap();
             for (int i = 0; i < str.length(); i++) {
                 char c = str.charAt(i);
                 if (!map.containsKey(c)) {
                     map.put(c, 1);
                 } else {
                     map.put(c, map.get(c) + 1);
                 }
             }
             ArrayList<Map.Entry<Character, Integer>> list = new ArrayList<>(map.entrySet());
             list.sort(new Comparator<Map.Entry<Character, Integer>>() {
                 @Override
                 public int compare(Map.Entry<Character, Integer> o1, Map.Entry<Character, Integer> o2) {
                     if(o1.getValue() < o2.getValue()){
                         return 1;
                     }else if(o1.getValue() > o2.getValue()){
                         return -1;
                     }else {
                         if (o1.getKey() > o2.getKey()){
                             return 1;
                         }else{
                             return -1;
                         }
                     }
                 }
             });
             for (Map.Entry<Character, Integer> m : list){
                 System.out.printf(m.getKey().toString());
             }
         }
     }
 }

